package com.briup.corejava.day21;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 使用类加载器加载资源为输入流
 */
public class Test2 {
    public static void main(String[] args) {
        Properties properties = new Properties();
        // 要调用load方法，需要准备输入流
        InputStream in = ClassLoader.getSystemClassLoader()
                .getResourceAsStream("com/briup/corejava/day21/jdbc.properties");
        System.out.println("in = " + in);
        try {
            properties.load(in);
            // 遍历
            properties.forEach((k,v)->{
                System.out.println(k + ":" +v);
            });
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
